<?php
namespace Plugins\shanyou;


include_once  "plugins/shanyou/lib.php";
include_once  "plugins/shanyou/config.php";

class submit
{
    
    private $H5path ="https://sdkh5.gouzixsw.com/#/";
    private $minePath ="https://sdkh5.gouzixsw.com/#/pages/mine/mine";
    
    public function __construct(){
        
    }

    public  function  setdata($userId,$data){
        $inc_type="shop_info";
        $shop_info=tpCache($inc_type);
        $shanyou_channnel_id=$shop_info["shanyou_channnel_id"];
        $shanyou_secret_key=$shop_info["shanyou_secret_key"];
        $data["sdkChannelId"]=$shanyou_channnel_id;
        $data["sdkUserId"]=$userId;
        $data["sdkVersion"]="1";
        $data["timestamp"]=time()."000";
        
        $lib = new lib();
        $signContent = $lib->ksortMd5($data,$shanyou_secret_key);
        $data["sign"]=$signContent;
        return $data;

    }
    
    public function getSign($userId){
        $inc_type="shop_info";
        $shop_info=tpCache($inc_type);
        $shanyou_channnel_id= trim($shop_info["shanyou_channnel_id"]);
        $shanyou_secret_key=trim($shop_info["shanyou_secret_key"]);
        $signContent = $shanyou_channnel_id."-".$shanyou_secret_key.":sdkUserId=".$userId."&";
        $sign =strtoupper(md5($signContent));
        return $sign;
    }
    


    public  function  getList($userId,$pageSize,$pageNum,$orderType){

        $data = array();
        $data["pageNum"]=$pageNum;
        $data["pageSize"]=$pageSize;
        $data["orderType"]=$orderType;
        $param = array();
        $param=$this->setdata($userId,$data);
        $url = config::apipath.config::listpath;
        $res= httpPost($url,$param);
        return $res;
    }

    public  function  getMyList($userId,$pageSize,$pageNum,$showStatus){
        $data = array();
        $data["pageNum"]=$pageNum;
        $data["pageSize"]=$pageSize;
        $data["showStatus"]=$showStatus;
        $param = array();
        $param=$this->setdata($userId,$data);
        $url = config::apipath.config::mylistpath;
        $res= httpPost($url,$param);
        return $res;
    }
    //获取个人详情
    public function getInfo($userId){
        $param = array();
        $param=$this->setdata($userId,$data);
        $url = config::apipath.config::mylistpath;
        $res= httpPost($url,$param);
        return $res;
    }

    public  function getTaskSearchList($userId,$pageSize,$pageNum,$keyword){
        $data = array();
        $data["pageNum"]=$pageNum;
        $data["pageSize"]=$pageSize;
        $data["keyword"]=$keyword;
        $param = array();
        $param=$this->setdata($userId,$data);
        $url = config::apipath.config::taskSearchList;
        $res= httpPost($url,$param);
        return $res;
    }

    public  function  getOneHourAuthTaskList($userId,$pageSize,$pageNum){
        $data = array();
        $data["pageNum"]=$pageNum;
        $data["pageSize"]=$pageSize;
        $param = array();
        $param=$this->setdata($userId,$data);
        $url = config::apipath.config::oneHourAuthTaskList;
        $res= httpPost($url,$param);
        return $res;
    }
    
    
    
    //获取首页的地址
    public function getH5IndexPath($userId){
        $inc_type="shop_info";
        $shop_info=tpCache($inc_type);
        $shanyou_channnel_id= trim($shop_info["shanyou_channnel_id"]);
        $shanyou_secret_key=trim($shop_info["shanyou_secret_key"]);
        $sign = $this->getSign($userId);
        $path =$this->H5path."?channelId=".$shanyou_channnel_id."&userId=".$userId."&sign=".$sign;
        return $path;
    }
    
    public function getH5minePath($userId){

        $inc_type="shop_info";
        $shop_info=tpCache($inc_type);
        $shanyou_channnel_id= trim($shop_info["shanyou_channnel_id"]);
        $shanyou_secret_key=trim($shop_info["shanyou_secret_key"]);
        $sign = $this->getSign($userId);
        $path =$this->minePath."?channelId=".$shanyou_channnel_id."&userId=".$userId."&sign=".$sign;
        return $path;
    }
    
    
    
    
    
}